<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property string $code_name 活码名称
 * @property string $code_logo 活码logo
 * @property int $page_mode 页面模式（0 = 标准模式，1 = 海报模式）
 * @property array $page_cfg 落地页设置
 * @property array $room_rule_cfg 群规则设置
 * @property int $visit_type 二维码切换方式：2=随机跳转 3=轮询访问 4=顺序切换
 * @property int $qrcode_vc_type 二维码访问上线类型 0=累计限制 1=每日限制
 * @property int $bind_device 用户设备绑定：0=关闭 1=开启
 * @property int $is_advanced 高级配置 0=关闭 1=开启
 * @property string $code 活码
 * @property int $status (1 = 使用中，2 = 已停用)
 * @property string $created_at 
 * @property string $poster 海报
 * @property string $render_url 快链
 * @property int $daily_visit 
 * @property int $total_visit 
 * @property int $join_visit 
 * @property int $daily_join_visit 
 * @property int $out_visit 
 * @property int $daily_out_visit 
 * @property-read null|\Hyperf\Database\Model\Collection|ChRoomCodeRoomRelation[] $room_list 
 * @property-read null|ChUser $user 
 */
class ChRoomCode extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_code';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'code_name', 'code_logo', 'page_mode', 'page_cfg', 'room_rule_cfg', 'visit_type', 'qrcode_vc_type', 'bind_device', 'is_advanced', 'code', 'status', 'created_at', 'poster', 'render_url', 'daily_visit', 'total_visit', 'join_visit', 'daily_join_visit', 'out_visit', 'daily_out_visit'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'page_mode' => 'integer', 'page_cfg' => 'array', 'room_rule_cfg' => 'array', 'visit_type' => 'integer', 'qrcode_vc_type' => 'integer', 'bind_device' => 'integer', 'is_advanced' => 'integer', 'status' => 'integer', 'daily_visit' => 'integer', 'total_visit' => 'integer', 'join_visit' => 'integer', 'daily_join_visit' => 'integer', 'out_visit' => 'integer', 'daily_out_visit' => 'integer'];

    public function room_list()
    {
        return $this->hasMany(ChRoomCodeRoomRelation::class, 'code_id', 'id');
    }

    public function user()
    {
        return $this -> hasOne(ChUser::class,'id','uid');
    }

}
